/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.moltos.game;

/**
 *
 * @author MoLt1eS
 */
public class ThreadDemo extends Thread {
    private Thread t;
    private String threadName;
    PrintDemo PD;
    
    ThreadDemo(String threadName, PrintDemo PD){
        this.threadName  = threadName;
        this.PD = PD;
    }
    
    public void run() {
        synchronized(PD){
            PD.printCount();
        }
        System.out.println("Thread "+threadName+" exiting.");
    }
    
    public void start(){
        System.out.println("Starting "+threadName);
        if(t == null){
            t = new Thread (this, threadName);
            t.start();
        }
    }
    
}
